#pragma once
#include <string>
#include <cstdio>
using namespace std;

template<typename T>
inline string hexBySize(const T& _obj)
{
	uint8_t *p = (uint8_t*)&_obj;

	string _data; 
	for(int i = 0; i < sizeof(_obj); i++)
	{
		char buf[8] = {0};
		snprintf(buf, sizeof(buf), " %02X", p[i]);
		_data += buf;
	}
	return _data;
}

template<typename T>
inline string hexByLength(const T& _obj)
{
	uint8_t *p = (uint8_t*)&_obj;

	string _data; 
	for(int i = 0; i < _obj.length(); i++)
	{
		char buf[8] = {0};
		snprintf(buf, sizeof(buf), " %02X", p[i]);
		_data += buf;
	}
	return _data;
}
